<div id="current-event" class="hidden" data-current-event=<%=current_event.id%>></div>
<div id="session-id" class="hidden" data-session-id=<%=params[:session_id]%>></div>
<div id="set-table-num" class="hidden" data-set-table-num=<%=@current_session_seat.properties['set_table_num']%>></div>

<div class="ibox-content">
  <div class="container-fluid">
    <div class="col-sm-5 m-b-xs">
      <%= link_to '全部', event_seats_path(current_event, display_type: 'attendee', session_id: params[:session_id]), class: "btn btn-white" %>
      <%= link_to '已安排', event_seats_path(current_event, display_type: 'attendee', session_id: params[:session_id], has_arranged: true), class: "btn btn-white" %>
      <%= link_to '未安排', event_seats_path(current_event, display_type: 'attendee', session_id: params[:session_id], has_arranged: false), class: 'btn btn-white' %>
    </div>

    <%= form_tag "/app/events/#{current_event.id}/seats", method: :get do%>
      <div class="col-sm-4">
        <div class="input-group">
          <input type="text" class="hidden" name="display_type" value="attendee" />
          <input type="text" class="hidden" name="session_id" value="<%= params[:session_id] %>" />
          <input type="text" placeholder="请输入关键字" class="input-sm form-control" name="keyword" value="<%=params[:keyword]%>">
          <span class="input-group-btn"><button type="submit" class="btn btn-sm btn-primary"> 搜索</button> </span>
        </div>
      </div>
    <% end %>
    <button id="cancel-button" class="hidden">取消</button>
    <div class="row">
      <table id="seat-attendee-table" class="table table-striped table-hover">
        <thead>
        <tr>
          <th>序号</th>
          <th>姓名</th>
          <th>省</th>
          <th>市</th>
          <th>公司</th>
          <th>手机号码</th>
          <th>座位号</th>
          <th>操作</th>
          <th class="hidden">嘉宾id</th>
        </tr>
        </thead>
        <tbody>
        <% @attendees.each do |attendee| %>
          <tr>
            <td><%=attendee.attendee_number%></td>
            <td><%=attendee.name%></td>
            <td><%=attendee.province%></td>
            <td><%=attendee.city%></td>
            <td><%=attendee.company%></td>
            <td><%=attendee.mobile%></td>
            <% seat = Seat.attendee_seat_is(attendee, @session).first %>
            <% if @current_session_seat.properties['set_table_num']=="true" %>
              <td><%= seat.present? ? "第#{seat.table_row} 桌, #{seat.table_col} 号" : '未安排' %></td>
            <% else %>
              <td><%= seat.present? ? "第#{seat.table_row} 桌" : '未安排' %></td>
            <% end %>
            <td id="update-seat"><button>变更</button></td>
            <td class="hidden"><%= attendee.id %></td>
            <td class=<%=seat.present? ? '' : 'hidden'%>><%= link_to '清除座位', event_seat_path(current_event, (seat.try(:id)||'~'), session_id: @session, display_type: 'attendee'), method: :delete, data: {confirm: '你确定清除该用户的座位吗？' } %></td>
          </tr>
        <% end %>
        </tbody>
      </table>

      <div class="col-sm-12">
        <%= paginate @attendees %>
      </div>
    </div>
  </div>
</div>
